package cn.wjzhang.middle.modules.area.controller;

import cn.wjzhang.core.beans.vo.Result;
import cn.wjzhang.middle.modules.area.beans.vo.MidAreasVo;
import cn.wjzhang.middle.modules.area.beans.request.MidAreasAddRequest;
import cn.wjzhang.middle.modules.area.beans.request.MidAreasEditRequest;
import cn.wjzhang.middle.modules.area.beans.request.MidAreasListRequest;
import cn.wjzhang.middle.modules.area.service.MidAreasService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 县级（区县）Controller层
 *
 * @author wjzhang
 * @date 2023-06-28 18:48:28
 */
@Slf4j
@Api(tags = "县级（区县）")
@RestController
@RequestMapping("/v1/midareas")
public class MidAreasController {
    @Resource
    private MidAreasService midAreasService;

    @ApiOperation("县级（区县）-分页列表查询")
    @GetMapping("/list")
    public Result<IPage<MidAreasVo>> queryPageList(MidAreasListRequest param) {
        return Result.ok(midAreasService.listWithPage(param));
    }

//    @ApiOperation("县级（区县）-添加")
//    @PostMapping("/add")
//    public Result<Long> add(@Validated @RequestBody MidAreasAddRequest addRequest) {
//        return Result.ok(this.midAreasService.addMidAreas(addRequest));
//    }
//
//    @ApiOperation("县级（区县）-编辑")
//    @PostMapping("/edit")
//    public Result edit(@Validated @RequestBody MidAreasEditRequest editRequest) {
//        this.midAreasService.editMidAreas(editRequest);
//        return Result.ok();
//    }
//
//    @ApiOperation("县级（区县）-通过id删除")
//    @PostMapping("/delete")
//    public Result delete(@RequestParam(name = "id") Long id) {
//        this.midAreasService.removeByIdLogic(id);
//        return Result.ok();
//    }

    @ApiOperation("县级（区县）-通过id查询")
    @GetMapping("/queryById")
    public Result<MidAreasVo> queryById(@RequestParam(name = "id") Long id) {
        return Result.ok(midAreasService.getDTO(id));
    }
}
